package three_autoAck;

import com.rabbitmq.client.Channel;
import util.RabbitMqUtils;

import java.util.Scanner;

/**
 * @BelongsProject: RabbitMQ
 * @BelongsPackage: autoAck
 * @Author: HUI
 * @CreateTime: 2022-04-13 10:40
 * @Description:
 */
public class Producer {

    private static final String QUEUE_NAME = "ack_queue";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();

        channel.queueDeclare(QUEUE_NAME, false, false, false, null);
        //从控制台当中接受信息
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String message = scanner.next();
            channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
            System.err.println("发送消息完成:" + message);

        }
    }
}
